package com.mall.shopping.services;

import com.mall.shopping.IContentService;
import com.mall.shopping.converter.ContentConverter;
import com.mall.shopping.dal.entitys.PanelContent;
import com.mall.shopping.dal.persistence.PanelContentMapper;
import com.mall.shopping.dto.NavListResponse;
import com.mall.shopping.dto.PanelContentDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author
 * @date 2020/12/20 1:46
 */
@Slf4j
@Service
@Component
public class ContentServiceImpl implements IContentService {
    @Autowired
    PanelContentMapper panelContentMapper;
    @Autowired
    ContentConverter contentConverter;

    @Override
    public NavListResponse queryNavList() {
        NavListResponse navListResponse = new NavListResponse();
        Example example = new Example(PanelContent.class);
        example.createCriteria().andEqualTo("panelId",0);
        List<PanelContent> panelContents = panelContentMapper.selectByExample(example);
        List<PanelContentDto> contentDtos = contentConverter.panelContents2Dto(panelContents);
        navListResponse.setPannelContentDtos(contentDtos);
        return navListResponse;
    }
}
